package com.bdqn.tour.servlet.Hzy;



import com.bdqn.tour.service.impl.HzyInvoiceServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/delInvoice")
public class DeleteInvoiceServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        this.doPost(req, resp);
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("utf-8");
        resp.setCharacterEncoding("utf-8");
        resp.setContentType("text/plain;charset=utf-8");

        String id = req.getParameter("id");
        int result = new HzyInvoiceServiceImpl().delInvoice(Integer.parseInt(id));
        resp.getWriter().write(result > 0 ? "删除成功" : "删除失败");
        resp.getWriter().close();
    }
}
